How do I add a domain user on my network, to be a  local admin of the machine on  windows 7 via vbs script
on error resume next const HKEY_LOCAL_MACHINE = &H80000002 strComputer = "." Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strComputer & "\root\default:StdRegProv") strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" strValueName = "AltDefaultUserName" oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE,strKeyPath,_ strValueName,strValue Set WSHShell = WScript.CreateObject("WScript.Shell") ReturnCode = WshShell.Run("cmd /c net localgroup administrators "&strValue&" /add", 0, True) dim message message = msgbox("A logoff/login is required to get local admin rights!" &Chr(13)& "Do you want to logoff now? ",vbyesno, "Local admin rights...") if message = vbyes then Set WSHShell = WScript.CreateObject("WScript.Shell") ReturnCode = WshShell.Run("shutdown -l -t 0", 0, True) else wscript.quit end if Hi guys, the above script works perfect in XP. What it does is, once we deploy the operating system on a remote PC, we usually install all other applications and drivers etc.. The Idea is to automate as much as possible, and sometimes we need to ad the user who is already in the domain as local admin of the PC in question, and for that I use that script above, the user only has to logout and login back again and he is admin. cooll Now! why my script does not work on windows 7 Profesional? I have the same situation where we install the PC via our deployment tool. CA DSM, and we push the script accross the network hoping it will do the same on windows 7 and it's not adding the local user as admin. Can somebody help me here? Thanks.
September 15th, 2011 10:56am

This is a forum for Microsoft Exchange deployment issues. You have posted in the wrong place. You should try one of the server or scripting forums. Simon.Simon Butler, Exchange MVP Blog | Exchange Resources | In the UK? Hire Me.
Free Windows Admin Tool Kit Click here and download it now
September 17th, 2011 11:31am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics